package com.aaa.controller;

import com.aaa.entity.Emp;
import com.aaa.service.EmpService;
import com.aaa.vo.Result;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/emp")
@CrossOrigin
public class EmpController {
    @Autowired
    private EmpService empService;

    @GetMapping("getAll/{currentPage}/{pageSize}")
    public Result<Page<Emp>> getAll(@PathVariable Integer currentPage, @PathVariable Integer pageSize) {
        return empService.findByPage(currentPage, pageSize);
    }

    @PostMapping("/findAll/{currentPage}/{pageSize}")
    public Result<IPage<Emp>> findAll(@PathVariable Integer currentPage, @PathVariable Integer pageSize) {
        return empService.queryDate(currentPage, pageSize);
    }

    @DeleteMapping("del/{empno}")
    public Result delete(@PathVariable Integer empno){
        boolean b = empService.removeById(empno);
        return new Result<>(200,"成功",b);
    }
}


